
function test() {
    var link_start;    
    var link_end;
    var paginator_start;      
    var paginator_end;
    
    link_start = $("input[name='link_start']").attr("value");
    link_end = $("input[name='link_end']").attr("value");
    paginator_start = $("input[name='paginator_start']").attr("value");
    paginator_end = $("input[name='paginator_end']").attr("value");
    $.post('index.php' , {
        a : 'links',
        link_start : link_start,
        link_end : link_end,
        paginator_start : paginator_start,
        paginator_end : paginator_end
    } , function(data){
        if(data == "ok")
            $("#result").attr("src", "ok.jpg");
    });    
}

function saveSettings() {
    var site_url;
    var name_start;
    var name_end;
    var art_start;
    var art_end;
    var price_start;
    var price_end;
    var desc_start;
    var desc_end;
    var har_start;
    var har_end;
    var img_start;
    var img_end;
    var big_img_search;
    var big_img_replace;
    
    site_url = $("input[name='url']").attr("value");
    name_start= $("input[name='tovar_name1']").attr("value");
    name_end = $("input[name='tovar_name2']").attr("value");
    art_start = $("input[name='art1']").attr("value");
    art_end = $("input[name='art2']").attr("value");
    price_start = $("input[name='price1']").attr("value");
    price_end = $("input[name='price2']").attr("value");
    desc_start = $("input[name='desc_full1']").attr("value");
    desc_end = $("input[name='desc_full2']").attr("value");
    har_start = $("input[name='har1']").attr("value");
    har_end = $("input[name='har2']").attr("value");
    img_start = $("input[name='img1']").attr("value");
    img_end = $("input[name='img2']").attr("value");   
    big_img_search = $("input[name='big_img1']").attr("value"); 
    big_img_replace = $("input[name='big_img2']").attr("value"); 
    $.post('index.php' , {
        a : 'save',
        url : site_url,
        tovar_name1 : name_start,
        tovar_name2 : name_end,
        art1 : art_start,
        art2 : art_end,
        price1 : price_start,
        price2 : price_end,
        desc_full1 : desc_start,
        desc_full2 : desc_end,
        har1 : har_start,
        har2 : har_end,
        img1 : img_start,
        img2 : img_end,
        search : big_img_search,
        replace : big_img_replace
    } , function(data){
        updateList();
    });
}

function updateList() {
    $.post('index.php' , {
        a : 'update'        
    } , function(data){
        var answer = JSON.parse(data);
        $('.setList').html('<select name="list" id="select"></select>');
        for(var i=0; i<answer.i; i++){
            $('#select').append("<option>"+answer[i].domain+"</option>");
        }
    });    
}

function loadSettings() {
    var sel = $('#select option:selected').val();
    $.post('index.php' , {
        a : 'load',
        url : sel
    } , function(data){
        var answer = JSON.parse(data);       
        $("input[name='url']").val(answer[0].domain);
        $("input[name='tovar_name1']").val(answer[0].name_start);
        $("input[name='tovar_name2']").val(answer[0].name_end);
        $("input[name='art1']").val(answer[0].art_start);
        $("input[name='art2']").val(answer[0].art_end);
        $("input[name='price1']").val(answer[0].price_start);
        $("input[name='price2']").val(answer[0].price_end);
        $("input[name='desc_full1']").val(answer[0].desc_start);
        $("input[name='desc_full2']").val(answer[0].desc_end);
        $("input[name='har1']").val(answer[0].har_start);
        $("input[name='har2']").val(answer[0].har_end);
        $("input[name='img1']").val(answer[0].img_start);
        $("input[name='img2']").val(answer[0].img_end);
        $("input[name='big_img1']").val(answer[0].search);
        $("input[name='big_img2']").val(answer[0].replace);
    }); 
}




